<include file="Public/header"/>
<include file="Public/menu"/>

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            首页
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页管理</a></li>
            <li class="active">首页促销</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title"></h3>


                        <div class="form-inline pull-right">
                            <form action="" method="get">
                                <fieldset>
                                    <div class="input-group input-group-sm">
                                        <span class="input-group-addon"><strong>货品名称</strong></span>
                                        <input type="text" class="form-control" placeholder="货品名称" name="name" value="">
                                    </div>

                                    <div class="input-group input-group-sm">
                                        <div class="input-group-btn">
                                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i>
                                            </button>
                                        </div>
                                    </div>

                                </fieldset>
                            </form>
                        </div>

                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tbody>

                            <tr>
                                <th><input type="checkbox" class="grid-select-all"></th>
                                <th>ID</th>
                                <th>货品名称</th>
                                <th>图片</th>
                                <th>货品描述</th>
                                <th>店铺市场价</th>
                                <th>店铺销售价</th>
                                <th>店铺库存</th>
                                <th>冻结库存</th>
                            </tr>
                            <foreach name="product_relation_msg" item="v">
                                <tr>
                                    <td><input type="checkbox" class="grid-item" data-id="{$v.store_pid}"  <if condition="in_array($v['store_pid'],$value)">checked</if> ></td>
                                    <td>{$v.store_pid}</td>
                                    <td>{$v.name}</td>
                                    <td><img style="width: 100px" src="{:getThumb($v['goods_id'])}" /></td>
                                    <td>{$v.spec_info}</td>
                                    <td>{$v.marketprice}</td>
                                    <td>{$v.price}</td>
                                    <td>{$v.store}</td>
                                    <td>{$v.freez}</td>

                                </tr>
                            </foreach>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;
                        <a class="btn btn-sm btn-info add-goods">保存</a>
                        {$show}


                    </div>

                    <!-- /.box-body -->
                </div>
            </div>
        </div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script>

    $(function () {

        $('.delete').click(function () {
            if(!confirm("确定删除？"))
            {
                return false;
            }
        })
    })

</script>
<script src="/Public/layer/layer.js"></script>
<script data-exec-on-popstate>

    $(function () {


        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });

        $('.add-goods').on('click', function () {
            var selected = [];

            $('.grid-item').each(function () {
                var id = $(this).data('id');

                if ($(this).is(':checked')) {
                    var goods_values = id + '-1';
                    selected.push(goods_values);
                } else {
                    var goods_values = id + '-0';
                    selected.push(goods_values);
                }
            });
            if (selected.length == 0) {
                return;
            }
            $.post('/admin/page/maShangMai', {data: selected}, function (data) {
                window.location.reload();
            });
        });
    });
</script>

